package com.huabo.contract.oracle.mapper;


import com.hbfk.util.PageInfo;
import com.huabo.contract.oracle.entity.TblAttachment;
import com.huabo.contract.oracle.entity.TblCyhwUnit;

import net.sf.json.JSONObject;

import java.math.BigDecimal;
import java.util.List;


import org.apache.ibatis.annotations.*;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author huabo
 * @since 2021-10-23
 */
@Mapper
public interface TblCyhwUnitMapper extends tk.mybatis.mapper.common.Mapper<TblCyhwUnit> {

//	@Select("SELECT COUNT(0) FROM TBL_CYHW_UNIT WHERE CONTRACTXDFXINFO = #{budgetid}")
//	Integer selectListByBudgetId(@Param("budgetid")Integer budgetid) throws Exception;

	@Select("SELECT * FROM TBL_CYHW_UNIT WHERE CONTRACTID = #{contractid}")
	TblCyhwUnit selectAllInfoById(BigDecimal contractid) throws Exception;


    @SelectProvider(type=TblCyhwUnitMapperSqlConfig.class,method="selectUnitListByPageInfo")
	List<TblCyhwUnit> selectUnitListByPageInfo(PageInfo<TblCyhwUnit> pageInfo, String orgid, String staffid, Integer paCount);

    @SelectProvider(type=TblCyhwUnitMapperSqlConfig.class,method="selectUnitCountByPageInfo")
    Integer selectUnitCountByPageInfo(PageInfo<TblCyhwUnit> pageInfo, String orgid, String staffid, Integer paCount);

	@SelectProvider(type=TblCyhwUnitMapperSqlConfig.class,method="selectLedgerListPageInfo")
    List<TblCyhwUnit> selectLedgerListPageInfo(PageInfo<TblCyhwUnit> pageInfo);

	@SelectProvider(type=TblCyhwUnitMapperSqlConfig.class,method="selectLedgerCountPageIfo")
	Integer selectLedgerCountPageIfo(PageInfo<TblCyhwUnit> pageInfo);

	@SelectProvider(type=TblCyhwUnitMapperSqlConfig.class,method="findLedgerListForExport")
	@Results({
		@Result(property="contractno",column="CONTRACTNO"),
		@Result(property="contractname",column="CONTRACTNAME"),
		@Result(property="recordConcatname",column="recordConcatname"),
		@Result(property="contracttype",column="CONTRACTTYPE"),
		@Result(property="contractitem",column="CONTRACTITEM"),
		@Result(property="dctype",column="DCTYPE"),
		@Result(property="contractmoney",column="CONTRACTMONEY"),
		@Result(property="createtime",column="CREATETIME"),
		@Result(property="startdate",column="STARTDATE"),
		@Result(property="enddate",column="ENDDATE"),
		@Result(property="choicejbunitid",column="choicejbunitid"),
		@Result(property="choicecontractDeptId",column="choicecontractDeptId"),
		@Result(property="topic",column="topic"),
		@Result(property="nodeCount",column="nodeCount"),
		@Result(property="yongyintime",column="yongyintime"),
		@Result(property="contractstatus",column="CONTRACTSTATUS"),
		@Result(property="topicname",column="TOPICNAME"),
	})
    List<TblCyhwUnit> findLedgerListForExport(TblCyhwUnit unit);
	
	
	@SelectProvider(type=TblCyhwUnitMapperSqlConfig.class,method="findCollectionChoiceContractPid")
    List<TblCyhwUnit> findCollectionChoiceContractPid(PageInfo<TblCyhwUnit> pageInfo, BigDecimal pid,String contractno,String contractname);

	@SelectProvider(type=TblCyhwUnitMapperSqlConfig.class,method="findCollectionChoiceContractPidCount")
	Integer findCollectionChoiceContractPidCount(BigDecimal pid, String contractno, String contractname);

	@SelectProvider(type=TblCyhwUnitMapperSqlConfig.class,method="selectCountByPageInfo")
	Integer selectCountByPageInfo(BigDecimal pid, String contractno, String contractname);

	@InsertProvider(type=TblCyhwUnitMapperSqlConfig.class,method="insertCyhwUnit")
	@Options(useGeneratedKeys=true, keyProperty="contractid", keyColumn="CONTRACTID")
    void insertCyhwUnit(TblCyhwUnit tcu);

	@Insert("INSERT INTO TBL_CYHW_UNIT_ATT(CONTRACTID,ATTID) VALUES(#{contractid},#{attId})")
	void insertAttmentRelation(@Param("attId")String id, @Param("contractid")BigDecimal contractid);

	@Select("SELECT CONTRACTSTATUS FROM TBL_CYHW_UNIT WHERE CONTRACTID = #{contractId}")
    Integer selectStatueById(Integer contractId);

	@UpdateProvider(method="updateCyhwUnit",type=TblCyhwUnitMapperSqlConfig.class)
    void updateCyhwUnit(TblCyhwUnit tcu);
	
	@UpdateProvider(method="updateCyhwUnitNoDescrpib",type=TblCyhwUnitMapperSqlConfig.class)
	void updateCyhwUnitNoDescrpib(TblCyhwUnit tcu);

	@Select("SELECT * FROM TBL_CYHW_UNIT WHERE  CONTRACTID = #{contractId}")
	TblCyhwUnit selectByContractId(BigDecimal contractId);

	@Update("UPDATE TBL_CYHW_UNIT SET CONTRACTSTATUS = #{contractstatus} WHERE CONTRACTID = #{contractid}")
	void updateContractStatus(TblCyhwUnit entity);

	@Delete("DELETE FROM TBL_CONTRACT_PLANNODE WHERE PROJECTID = #{contractId}")
    void deletePlannode(Integer contractId);

	@Delete("DELETE FROM TBL_ATTACHMENT WHERE ATTID IN (SELECT ATTID FROM TBL_CYHW_UNIT_ATT WHERE CONTRACTID = #{contractId}) ")
	void deleteattachment(Integer contractId);

	@Delete("DELETE FROM TBL_CYHW_UNIT_ATT WHERE CONTRACTID = #{contractId}")
	void deleteUnitaTT(Integer contractId);

	@Delete("DELETE FROM TBL_CONTRACT_INFORMATION WHERE PROJECTID = #{contractId}")
	void deleteInformation(Integer contractId);

	@Delete("DELETE FROM TBL_CYHW_UNIT WHERE CONTRACTID = #{contractId}")
	void deleteunit(Integer contractId);

	@Select("SELECT T.CONTRACTID,T.FLOWID,T.UNITNAME,T.CONTRACTNAME,T.CONTRACTITEM,T.CONTRACTNO,T.CONTRACTDEPT,T.CONTRACTLINK,T.CONTRACTMONEY,T.CONTRACTSTATUS,T.LINKDEPT,T.ORGID,T.CREATEUSER,T.CREATETIME,T.MOMOCONCAT,T.RISKCONTROL,T.DESCRIBE,T.CONTRACTSTAFF,T.SCRILEVEL,T.STARTDATE,T.ENDDATE,T.CONTRACTTYPE,T.CONTRACTDATETYPE,T.CONTRACTXZ,T.CONTRACTXDFXINFO,T.RECORDTYPE,T.RECORDPARENT,T.HZSUMOWING,T.JIJIATYPE,T.MONEYTYPE,T.DCTYPE,T.CONTRACTBD,T.CONTRACTZD,T.JBSTAFF,T.JBDEPT,T.JBUNIT,T.ZXUNIT,T.CONTRACTCHILDREN,T.CONTRACTPLAN,T.TOPICID,TCPJ.PROJECTNAME,T.HISCONTRACTSTATUS,T.CHANGETYPE,T.CHANGEDATE,T.CHANGEDESC,T.ISDG,T.COUNTERPARTBANK,T.CONTRACTQUFEN,T.REWORKFLOW,T.ISMOREMILLION,T.FUNDPOOLNAME,o.ORGMENO,s.REALNAME,c.COUNTERPARTNO,c.BUDGETNAME,c.TOTALTMONEY,c.COUNTERPARTTYPE,c.PROJECTSTAGEGOAL,c.COUNTERPARTADDRESS,c.COUNTERPARTPHONE,c.COUNTERPARTCODE,oz.ORGNAME,cb.BANKID,cb.BANKACCOUNT,cb.BANKKHYH FROM TBL_CYHW_UNIT T " +
			" left join TBL_ORGANIZATION o on t.CONTRACTDEPT = o.ORGID " +
			" left join TBL_STAFF s on t.CONTRACTSTAFF = s.STAFFID " +
			" left join TBL_CYHW_PROJECTBUDGET c on t.CONTRACTXDFXINFO = c.BUDGETID " +
			" left join TBL_ORGANIZATION oz on t.ZXUNIT = oz.ORGID " +
			" left join TBL_COUNTERPART_BANKINFO cb on t.COUNTERPARTBANK = cb.BANKID LEFT JOIN TBL_CONTRACT_PROJECT TCPJ ON T.TOPICID = TCPJ.PROJECTID "+
			" WHERE t.CONTRACTID = #{contractId}")
	@Results({
			@Result(column="BANKID",property="bankinfo.bankid"),
			@Result(column="BANKACCOUNT",property="bankinfo.bankaccount"),
			@Result(column="BANKKHYH",property="bankinfo.bankkhyh"),
			@Result(column="PROJECTNAME",property="topicname")
	})
	TblCyhwUnit getCyhwUnitEntity(int contractId);

	@SelectProvider(type=TblCyhwUnitMapperSqlConfig.class,method="selectListByPageInfo")
    List<TblCyhwUnit> selectListByPageInfo(PageInfo<TblCyhwUnit> pageInfo, TblCyhwUnit unit);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "selectCountByPageInfoCount")
	Integer selectCountByPageInfoCount(TblCyhwUnit unit);

	@Select("SELECT * FROM TBL_CYHW_UNIT TCU\n" +
			"LEFT JOIN TBL_FLOW TF ON TCU.FLOWID = TF.FLOWID\n" +
			"WHERE CONTRACTID = #{contractId}")
    TblCyhwUnit selectChangeContractInfo(BigDecimal contractid);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findListByPageInfo")
    List<TblCyhwUnit> findListByPageInfo(PageInfo<TblCyhwUnit> pageInfo, String orgid);
	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findCountByPageInfoCount")
	Integer findCountByPageInfoCount(PageInfo<TblCyhwUnit> pageInfo, String orgid);

	@Select("SELECT T.CONTRACTID,T.FLOWID,T.UNITNAME,T.CONTRACTNAME,T.CONTRACTITEM,T.CONTRACTNO,T.CONTRACTDEPT,T.CONTRACTLINK,T.CONTRACTMONEY,T.CONTRACTSTATUS,T.LINKDEPT,T.ORGID,T.CREATEUSER,T.CREATETIME,T.MOMOCONCAT,T.RISKCONTROL,T.DESCRIBE,T.CONTRACTSTAFF,T.SCRILEVEL,T.STARTDATE,T.ENDDATE,TCPJ.PROJECTNAME AS TOPICNAME,T.CONTRACTTYPE,T.CONTRACTDATETYPE,T.CONTRACTXZ,T.CONTRACTXDFXINFO,T.RECORDTYPE,T.RECORDPARENT,T.HZSUMOWING,T.JIJIATYPE,T.MONEYTYPE,T.DCTYPE,T.CONTRACTBD,T.CONTRACTZD,T.JBSTAFF,T.JBDEPT,T.JBUNIT,T.ZXUNIT,T.CONTRACTCHILDREN,T.CONTRACTPLAN,T.TOPICID,T.TOPICNAME,T.HISCONTRACTSTATUS,T.CHANGETYPE,T.CHANGEDATE,T.CHANGEDESC,T.ISDG,T.COUNTERPARTBANK,T.CONTRACTQUFEN,T.REWORKFLOW,T.ISMOREMILLION,T.FUNDPOOLNAME FROM TBL_CYHW_UNIT  T LEFT JOIN TBL_CONTRACT_PROJECT TCPJ ON T.TOPICID = TCPJ.PROJECTID where CONTRACTID = #{contractId}")
    TblCyhwUnit findContractById(Integer contractId);

	@Update("UPDATE TBL_CYHW_UNIT SET HISCONTRACTSTATUS = #{historyStatus},CONTRACTSTATUS = #{currentStatus} WHERE CONTRACTID = #{contractId} ")
    void updateModifyContractStatus(BigDecimal historyStatus, Integer currentStatus, BigDecimal contractId);

	@Update("UPDATE TBL_CYHW_UNIT SET  HISCONTRACTSTATUS = #{hiscontractstatus},CONTRACTSTATUS = #{hiscontractstatus1} WHERE CONTRACTID = #{contractid} ")
    void updateStatus(BigDecimal hiscontractstatus, BigDecimal hiscontractstatus1, BigDecimal contractid);

	@Select("SELECT CONTRACTMONEY FROM TBL_CYHW_UNIT WHERE CONTRACTID =#{contractId}")
    BigDecimal findContractMoneyByContractId(Integer contractId);

//	@Select("SELECT * FROM TBL_CYHW_UNIT WHERE RECORDTYPE = #{recordType} AND  CONTRACTID = #{parentId}")
//	TblCyhwUnit findeContractInfo(@Param("parentId") Integer parentId, @Param("recordType")String recordType);

		@Select("SELECT T.CONTRACTID,T.FLOWID,T.UNITNAME,T.CONTRACTNAME,T.CONTRACTITEM,T.CONTRACTNO,T.CONTRACTDEPT,T.CONTRACTLINK,T.CONTRACTMONEY,T.CONTRACTSTATUS,T.LINKDEPT,T.ORGID,T.CREATEUSER,T.CREATETIME,T.MOMOCONCAT,T.RISKCONTROL,T.DESCRIBE,T.CONTRACTSTAFF,T.SCRILEVEL,T.STARTDATE,T.ENDDATE,TCPJ.PROJECTNAME AS TOPICNAME,T.CONTRACTTYPE,T.CONTRACTDATETYPE,T.CONTRACTXZ,T.CONTRACTXDFXINFO,T.RECORDTYPE,T.RECORDPARENT,T.HZSUMOWING,T.JIJIATYPE,T.MONEYTYPE,T.DCTYPE,T.CONTRACTBD,T.CONTRACTZD,T.JBSTAFF,T.JBDEPT,T.JBUNIT,T.ZXUNIT,T.CONTRACTCHILDREN,T.CONTRACTPLAN,T.TOPICID,T.TOPICNAME,T.HISCONTRACTSTATUS,T.CHANGETYPE,T.CHANGEDATE,T.CHANGEDESC,T.ISDG,T.COUNTERPARTBANK,T.CONTRACTQUFEN,T.REWORKFLOW,T.ISMOREMILLION,T.FUNDPOOLNAME,o.ORGMENO,s.REALNAME,c.COUNTERPARTNO,c.BUDGETNAME,c.TOTALTMONEY,c.COUNTERPARTTYPE,c.PROJECTSTAGEGOAL,c.COUNTERPARTADDRESS,c.COUNTERPARTPHONE,c.COUNTERPARTCODE,oz.ORGNAME,cb.BANKID,cb.BANKACCOUNT,cb.BANKKHYH FROM TBL_CYHW_UNIT t " +
				" left join TBL_ORGANIZATION o on t.CONTRACTDEPT = o.ORGID " +
				" left join TBL_STAFF s on t.CONTRACTSTAFF = s.STAFFID " +
				" left join TBL_CYHW_PROJECTBUDGET c on t.CONTRACTXDFXINFO = c.BUDGETID " +
				" left join TBL_ORGANIZATION oz on t.ZXUNIT = oz.ORGID " +
				" left join TBL_COUNTERPART_BANKINFO cb on t.COUNTERPARTBANK = cb.BANKID LEFT JOIN TBL_CONTRACT_PROJECT TCPJ ON T.TOPICID = TCPJ.PROJECTID "+
				" WHERE t.RECORDTYPE = #{recordType} AND  t.CONTRACTID = #{parentId}")
		@Results({
				@Result(column="BANKID",property="bankinfo.bankid"),
				@Result(column="BANKACCOUNT",property="bankinfo.bankaccount"),
				@Result(column="BANKKHYH",property="bankinfo.bankkhyh")
		})
	TblCyhwUnit findeContractInfo(@Param("parentId") Integer parentId, @Param("recordType")String recordType);

	@Select("SELECT CONTRACTID,FLOWID,CONTRACTNAME,CONTRACTNO,CONTRACTMONEY,CONTRACTTYPE,CREATETIME,RECORDTYPE FROM TBL_CYHW_UNIT WHERE CONTRACTID != #{contractid} START WITH CONTRACTID = #{contractid} CONNECT BY PRIOR RECORDPARENT = CONTRACTID ORDER BY CREATETIME DESC")
	List<TblCyhwUnit> findAllParentList(BigDecimal contractid);

//	@Select("SELECT ATTID,ATTNAME,ATTPATH,ATTSIZE,MEMO,UPLOADTIME,UPLOADER FROM TBL_ATTACHMENT WHERE ATTID IN (SELECT ATTID FROM TBL_CYHW_PROJECTBUDGET_ATT WHERE BUDGETID IN (SELECT BUDGETID FROM TBL_CYHW_PROJECTBUDGET WHERE RECORDTYPE = 'HTGL003' AND ORGID = #{orgid} AND RECORDPARENT = #{contractId}))")
//	List<TblAttachment> findContractSealFileList(@Param("orgid")BigDecimal orgid,@Param("contractId")Integer contractId);
	
	@Select("SELECT ATTID,ATTNAME,ATTPATH,ATTSIZE,MEMO,UPLOADTIME,UPLOADER FROM TBL_ATTACHMENT WHERE ATTID IN (SELECT ATTID FROM TBL_CYHW_UNIT_ATT WHERE contractId = #{contractId})")
	List<TblAttachment> findContractSealFileList(@Param("orgid")BigDecimal orgid,@Param("contractId")Integer contractId);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findContractSealList")
	List<TblCyhwUnit> findContractSealList(PageInfo<TblCyhwUnit> pageInfo);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findCountContractSealList")
	Integer findCountContractSealList(PageInfo<TblCyhwUnit> pageInfo);

	@Update("UPDATE TBL_CYHW_UNIT SET HISCONTRACTSTATUS = #{hiscontractstatus},CONTRACTSTATUS = #{currentStatus} WHERE CONTRACTID = #{contractid}")
    void updateModifyContrac(BigDecimal hiscontractstatus, BigDecimal currentStatus, BigDecimal contractid);

	@Update("UPDATE TBL_CYHW_UNIT SET HISCONTRACTSTATUS = #{hiscontractstatus},CONTRACTSTATUS=#{hiscontractstatus1} WHERE CONTRACTID = #{contractid}")
    void modifyContract(BigDecimal hiscontractstatus, BigDecimal hiscontractstatus1, BigDecimal contractid);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findeFilContractList")
    List<TblCyhwUnit> findeFilContractList(PageInfo<TblCyhwUnit> pageInfo);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findeCountFilContractList")
	Integer findeCountFilContractList(PageInfo<TblCyhwUnit> pageInfo);

	@Select("SELECT * FROM TBL_CYHW_UNIT where RECORDPARENT = #{recordparent}")
	TblCyhwUnit findContractByParentId(BigDecimal recordparent);

	@Update("UPDATE TBL_CYHW_UNIT SET CONTRACTSTATUS = #{status} WHERE CONTRACTID =  #{contractid} ")
	void modifyContractStatus(BigDecimal contractid, String status);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findeContractListByContractStaff")
	List<TblCyhwUnit> findeContractListByContractStaff(PageInfo<TblCyhwUnit> pageInfo);
	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findeCountContractListByContractStaff")
	Integer findeCountContractListByContractStaff(PageInfo<TblCyhwUnit> pageInfo);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findeContractListPerformanceTracking")
    List<TblCyhwUnit> findeContractListPerformanceTracking(PageInfo<TblCyhwUnit> pageInfo);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findeCountContractListPerformanceTracking")
	Integer findeCountContractListPerformanceTracking(PageInfo<TblCyhwUnit> pageInfo);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findFulfillmentContract")
    List<TblCyhwUnit> findFulfillmentContract(PageInfo<TblCyhwUnit> pageInfo);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findCountFulfillmentContract")
	Integer findCountFulfillmentContract(PageInfo<TblCyhwUnit> pageInfo);

	@Update("UPDATE TBL_CYHW_UNIT SET HISCONTRACTSTATUS=CONTRACTSTATUS,CONTRACTSTATUS = #{goalStatus} WHERE CONTRACTID =  #{contractId}")
	void updaContractStatus(String contractId, int goalStatus);


	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findLegalContractListByPageInfo")
    List<TblCyhwUnit> findLegalContractListByPageInfo(PageInfo<TblCyhwUnit> pageInfo, TblCyhwUnit tcu);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findLegalContractListByPageInfoCount")
	Integer findLegalContractListByPageInfoCount(TblCyhwUnit tcu);

	@Select("SELECT T.CONTRACTID,T.FLOWID,T.UNITNAME,T.CONTRACTNAME,T.CONTRACTNO,T.CONTRACTDEPT,T.CONTRACTLINK,T.CONTRACTMONEY,T.CONTRACTSTATUS,T.LINKDEPT,T.CONTRACTITEM,T.ORGID,T.CREATEUSER,T.CREATETIME,T.MOMOCONCAT,T.RISKCONTROL,T.DESCRIBE,T.CONTRACTSTAFF,T.SCRILEVEL,T.STARTDATE,T.ENDDATE,TCPJ.PROJECTNAME AS TOPICNAME,T.CONTRACTTYPE,T.CONTRACTDATETYPE,T.CONTRACTXZ,T.CONTRACTXDFXINFO,T.RECORDTYPE,T.RECORDPARENT,T.HZSUMOWING,T.JIJIATYPE,T.MONEYTYPE,T.DCTYPE,T.CONTRACTBD,T.CONTRACTZD,T.JBSTAFF,T.JBDEPT,T.JBUNIT,T.ZXUNIT,T.CONTRACTCHILDREN,T.CONTRACTPLAN,T.TOPICID,T.TOPICNAME,T.HISCONTRACTSTATUS,T.CHANGETYPE,T.CHANGEDATE,T.CHANGEDESC,T.ISDG,T.COUNTERPARTBANK,T.CONTRACTQUFEN,T.REWORKFLOW,T.ISMOREMILLION,T.FUNDPOOLNAME,oz.ORGNAME FROM TBL_CYHW_UNIT T " + 
			" left join TBL_ORGANIZATION oz on T.ZXUNIT = oz.ORGID " + 
			" LEFT JOIN TBL_CONTRACT_PROJECT TCPJ ON T.TOPICID = TCPJ.PROJECTID " + 
			" WHERE CONTRACTID = #{recordparent}")
	@Results({
		@Result(column="ORGNAME",property="orgname"),
	})
    TblCyhwUnit getEntity(Integer recordparent);

//	@Select("SELECT MAX(TO_NUMBER(SUBSTR(CONTRACTNO,LENGTH(#{contractno})+1,LENGTH(CONTRACTNO)-LENGTH(#{contractno})))) FROM TBL_CYHW_UNIT WHERE RECORDTYPE = #{recordType} AND CONTRACTNO LIKE #{contractno} ")
//	String selectCountByContractNo(String contractno, String recordType) throws Exception;
	
	@Select("SELECT MAX(TO_NUMBER(SUBSTR(CONTRACTNO,LENGTH(#{contractno})+1,LENGTH(CONTRACTNO)-LENGTH(#{contractno})-1)))  "
			+ " FROM TBL_CYHW_UNIT "
			+ " WHERE RECORDTYPE = #{recordType} AND CONTRACTNO LIKE #{contractnolike} ")
	String selectCountByContractNo(String contractno,String contractnolike, String recordType) throws Exception;
	
	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findListByXdf")
    List<TblCyhwUnit> findListByXdf(PageInfo<TblCyhwUnit> pageInfo, String budgetid);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findListByXdfCount")
	Integer findListByXdfCount(String budgetid);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findListContractBiangengBypage")
    List<TblCyhwUnit> findListContractBiangengBypage(PageInfo<TblCyhwUnit> pageInfo, BigDecimal orgid, String userid, boolean findByModuel);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findListContractBiangengBypageCount")
	Integer findListContractBiangengBypageCount(BigDecimal orgid, String userid, boolean findByModuel);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findListByPage")
	List<TblCyhwUnit> findListByPage(PageInfo<TblCyhwUnit> pageInfo, BigDecimal orgid);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findListByPageCount")
	Integer findListByPageCount(BigDecimal orgid);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findListByPa")
	List<TblCyhwUnit> findListByPa(PageInfo<TblCyhwUnit> pageInfo, String userid, BigDecimal orgid);

	@SelectProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findListByPaCount")
	Integer findListByPaCount(String userid, BigDecimal orgid);

	@Select("SELECT CONTRACTID,FLOWID,CONTRACTNAME,CONTRACTNO,CONTRACTMONEY,CONTRACTTYPE,CREATETIME,RECORDTYPE FROM TBL_CYHW_UNIT WHERE CONTRACTXDFXINFO =#{budgetid}")
    List<TblCyhwUnit> selectAllParentInfoList(Integer budgetid);

	@Select("SELECT CONTRACTID,FLOWID,CONTRACTNAME,CONTRACTNO,CONTRACTMONEY,CONTRACTTYPE,CREATETIME,RECORDTYPE FROM TBL_CYHW_UNIT WHERE CONTRACTXDFXINFO =#{budgetid}")
	List<TblCyhwUnit> selectListByBudgetId(Integer budgetid);

	@Select("SELECT contractId,MOMOCONCAT,describe,contractName  FROM TBL_CYHW_UNIT WHERE recordType = 'HTGL007' AND contractType = #{contractType} AND orgid = #{orgid} AND contractStatus = 6")
    List<TblCyhwUnit> selectContractTemp(BigDecimal orgid, String contractType);

	@Select("SELECT DESCRIBE FROM TBL_CYHW_UNIT WHERE CONTRACTID = #{budgetId}")
	String findContractDes(String budgetId);

	@SelectProvider(method="getList",type=TblCyhwUnitMapperSqlConfig.class)
	 List<JSONObject>  getList(String orgid,String startDate);

	 @Select("SELECT ATTID,ATTNAME,ATTPATH,ATTSIZE from TBL_ATTACHMENT WHERE ATTID IN (SELECT ATTID FROM TBL_CYHW_UNIT_ATT WHERE CONTRACTID =#{contractid} )")
	    List<TblAttachment> findeFileInfo(Integer contractid);


	@Select("SELECT FLOWID FROM TBL_CYHW_UNIT WHERE CONTRACTID = #{contractid}")
	String selectContracFlowIdByContractId(Integer contractid);



//	@Select("Select * from TBL_CYHW_UNIT_ATT where ATTID")
//	TblCyhwUnitAtt findByAttid(String id);


//	@InsertProvider(type = TblCyhwUnitMapperSqlConfig.class,method = "findLegalContractListByPageInfoCount")
//	void saveContractInfoMation(TblCyhwUnit tcu);
}
